
****** Figure 2 Average Number of Duties
* set maxvar 10000
use "Data_Duties_Master.dta", clear

gen duties_total2 = . 
replace duties_total2 = duties_total if duties_total!=0
replace duties_total2 = . if duties_total==.



collapse (p25) p25_duties_total2=duties_total2 (p50) p50_duties_total2=duties_total2 (p75) p75_duties_total2=duties_total2, by(year)

* Now, create a line plot for each percentile
twoway (line p25_duties_total2 year, lcolor(blue) lpattern(dot) lwidth(thick)) ///
       (line p50_duties_total2 year, lcolor(red) lpattern(solid) lwidth(thick)) ///
       (line p75_duties_total2 year, lcolor(green) lpattern(dash) lwidth(thick)), ///
       xtitle("Year") ytitle("Number of Duties") xlabel(1781 1800(25)2000 2017)  ///
	   yscale(noextend) xscale(noextend)  ylabel(0(1)10)  ///
       legend(order(1 "25th Percentile" 2 "50th Percentile (Median)" 3 "75th Percentile") position(6) ///
	   cols(3) region(lstyle(none)))
	   
graph export "Figure_2.pdf", replace
